package cn.adair.oxframe.sample;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.google.android.material.bottomsheet.BottomSheetBehavior;

import butterknife.BindView;
import butterknife.OnClick;
import cn.adair.oxframe.base.OxBaseActivity;
import cn.adair.oxframe.drawer.CustomDrawer;
import cn.adair.oxframe.views.OxStatusbar;

@SuppressLint("NonConstantResourceId")
public class MainActivity extends OxBaseActivity {

    @Override
    protected void _SetStatusBar() {
        OxStatusbar.setColor(_mActivity, Color.parseColor("#FFFFFF"), 0);
        OxStatusbar.setLightMode(_mActivity);
    }

    @Override
    public int initLayout() {
        return R.layout.activity_main;
    }

    @BindView(R.id.hello)
    TextView hello;
    @BindView(R.id.bottom_sheet)
    RelativeLayout bottomSheet;

    private BottomSheetBehavior<View> behavior;

    @Override
    public void initData(Bundle savedInstanceState) {
        behavior = BottomSheetBehavior.from(bottomSheet);
        behavior.setState(BottomSheetBehavior.STATE_HIDDEN); // 默认关闭
        hello.setText("Activity Hello Oxframe");
    }


    @OnClick(R.id.jump_fragment)
    public void iJumpFragment() {
        Intent intent = new Intent();
        intent.setClass(_mContext, FragmentActivity.class);
        startActivity(intent);
    }

    @OnClick(R.id.open_drawer)
    public void iOpenDrawer() {
        CustomDrawer.instance().setCustomListener(new CustomDrawer.OnCustomListener() {
            @Override
            public void dismiss() {
                Toast.makeText(_mContext, "关闭抽屉", Toast.LENGTH_LONG).show();
            }
        }).show(getSupportFragmentManager());
    }

    @OnClick(R.id.open_drawer2)
    public void iOpenDrawer2() {
        //根据状态不同显示隐藏
        if (behavior.getState() == BottomSheetBehavior.STATE_EXPANDED) {
            behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
        } else {
            behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
        }
    }


}